<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<link  rel="stylesheet" href="__PUBLIC__/qwadmin/css/datatables.css" />
<link  rel="stylesheet" href="__PUBLIC__/qwadmin/css/linetime.css" />
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-md-12">
							  <div class="panel panel-default">
								<div class="panel-body table-responsive">

									<table id="example0" class="table display">
										<thead>
											<tr>
												<th>earn13码</th>
												<th>sku</th>
												<th>产品名称</th>
												<th>采购数量</th>
												<th>异常信息</th>
												<th>验证时间</th>
                                                <th>操作</th>
											</tr>
										</thead>
										<tbody>
											<tr>
												<td colspan="8" style="text-align:center;font-size:14px;">正在加载......</td>
											</tr>
										</tbody>
									</table>


								</div>

							  </div>
							</div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->
<div style="display:none;" class="modal fade bs-example-modal-lg in" id="personAddModel" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">  
    <div class="modal-dialog modal-lg">  
        <div class="modal-content" id="personAddModelContent">  
            <div class="modal-header nav nav-tabs" style="padding-bottom: 0px;">  
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>  
				<li class="active"><a href="#identifier" data-toggle="tab">销售订单</a></li>
				<li><a href="#identifier" data-toggle="tab">库存分拣</a></li>
				<li><a href="#identifier" data-toggle="tab">采购清单</a></li>
				<li><a href="#identifier" data-toggle="tab">进境清单</a></li>
            </div>  
  
        <div class="modal-body">  
            <div class="row">  
               <div class="col-xs-12" id="managerList">
                    <div class="panel panel-default" style="border:none">
						<div class="panel-body table-responsive">
							<table id="example1" class="table display">
								<thead>
									<tr>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td colspan="8" style="text-align:center;font-size:14px;">正在加载......</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
               </div>  
            </div>  
        </div>  
    </div>  
</div>
<include file="Public/footerjs"/>
<script src="__PUBLIC__/qwadmin/js/dataTables/datatables.min.js"></script>
<script>
	var data = {:json_encode($lists)};
	$(document).ready(function() {
		$('#example0').dataTable({ 
            "aLengthMenu" : [15, 30, 60], //更改显示记录数选项  
            "iDisplayLength" : 15, //默认显示的记录数    
			"data":data,
			"columns":[
				{data:'earn13'},
				{data:'sku'},
				{data:'name'},
				{data:'num'},
				{data:'info'},
				{data:'check_time'},
				{data:'sku'}
			],
			"fnRowCallback": function(nRow, aData, iDisplayIndex) {
				 $('td:eq(6)', nRow).html("<a href='?sku="+aData.sku+"' data-sku='"+aData.sku+"' id='show_data_info'>查看详情</a>");
				 return nRow;
			},
			"sPaginationType": "full_numbers",
			"bStateSave": true,
            "oLanguage": { //国际化配置    
	            "sLengthMenu" : "显示 _MENU_ 条",    
	            "sZeroRecords" : "没有您要搜索的内容",
	            "sInfo" : "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",    
	            "sInfoEmpty" : "记录数为0",    
	            "sInfoFiltered" : "(全部记录数 _MAX_ 条)",    
	            "sInfoPostFix" : "",    
	            "sSearch" : "搜索",    
	            "sUrl" : "",    
	            "oPaginate": {    
	                "sFirst" : "第一页",    
	                "sPrevious" : "上一页",    
	                "sNext" : "下一页",    
	                "sLast" : "最后一页"    
	            }  
	    	}
		});
		$(document).on( 'click', 'a#show_data_info' , function(){
			var _self = $(this);
			$(".modal-header li.active").removeClass( 'active' );
        	$(".modal-header li").eq(0).addClass('active');
            $('#personAddModel').modal('show');  
            $(".modal-header li").each(function(){ $(this).attr('data-sku' , _self.attr('data-sku') ); });
            $.get("{:U('Warning/getData')}",{sku:_self.attr('data-sku')},function( data ){
                loadDataShow( data.data , 0 , _self.attr('data-sku'));
            } , 'json');
            return false;
        });

        $(document).on('click' ,".modal-header li" , function(){
        	var _self = $(this);
        	var index = _self.index() - 1;
        	switch( index ) {
        		case 0 :
        			var url = "{:U('Warning/getData')}";
        		break;
        		case 1 :
        			var url = "{:U('Warning/getRmData')}";
        		break;
        		case 2 :
        			var url = "{:U('Warning/getPurchaseList')}";
        		break;
        		case 3 :
        			var url = "{:U('Warning/getTransOrderLines')}";
        		break;
        	}
        	$(".modal-header li.active").removeClass( 'active' );
        	$(".modal-header li").eq( index ).addClass('active');
        	$.get( url ,{sku:_self.attr('data-sku')},function( data ){
                loadDataShow( data.data , index , _self.attr('data-sku') );
            } , 'json');
        });

        //数据加载显示
        function loadDataShow( data , index , sku) {
        	switch( index ) {
        		case 0 :
        			var menu = [
						{"sTitle" : "来源渠道","mDataProp":"channel_code"},
						{"sTitle" : "贸易模式","mDataProp":"trade_pattern"},
						{"sTitle" : "订单号","mDataProp":"ref"},
						{"sTitle" : "购买人","mDataProp":"buyer"},
						{"sTitle" : "购买单价","mDataProp":"price"},
						{"sTitle" : "购买数量","mDataProp":"num"},
						{"sTitle" : "订单时间","mDataProp":"date_order"}
					];
					var columns = [
						{data:'channel_code'},
						{data:'trade_pattern'},
						{data:'ref'},
						{data:'buyer'},
						{data:'price'},
						{data:'num'},
						{data:'date_order'}
					];
        		break;
        		case 1 :
        			var menu = [
						{"sTitle" : "批次号","mDataProp":"picking_id"},
						{"sTitle" : "库存变化","mDataProp":"qty_act"},
						{"sTitle" : "来源","mDataProp":"location_id"},
						{"sTitle" : "目的","mDataProp":"location_dest_id"},
						{"sTitle" : "移动方向","mDataProp":"procure_method"},
						{"sTitle" : "状态","mDataProp":"state"},
						{"sTitle" : "时间","mDataProp":"date"}
					];
					var columns = [
						{data:'picking_id'},
						{data:'qty_act'},
						{data:'location_id'},
						{data:'location_dest_id'},
						{data:'procure_method'},
						{data:'state'},
						{data:'date'}
					];
        		break;
        		case 2 :
        			var menu = [
						{"sTitle" : "earn13码","mDataProp":"earn13"},
						{"sTitle" : "采购单号","mDataProp":"poname"},
						{"sTitle" : "商品名称","mDataProp":"name"},
						{"sTitle" : "采购数量","mDataProp":"num"},
						{"sTitle" : "目的地","mDataProp":"warehouse"},
						{"sTitle" : "状态","mDataProp":"state"},
						{"sTitle" : "采购时间","mDataProp":"date_purch"}
					];
					var columns = [
						{data:'earn13'},
						{data:'poname'},
						{data:'name'},
						{data:'num'},
						{data:'warehouse'},
						{data:'state'},
						{data:'date_purch'}
					];
        		break;
        		case 3 :
        			var menu = [
						{"sTitle" : "编号","mDataProp":"toname"},
						{"sTitle" : "供应商","mDataProp":"supplier"},
						{"sTitle" : "仓库","mDataProp":"warehouse_code"},
						{"sTitle" : "数量","mDataProp":"qty"},
						{"sTitle" : "采购单号","mDataProp":"poname"},
						{"sTitle" : "状态","mDataProp":"state"},
						{"sTitle" : "时间","mDataProp":"ttime"}
					];
					var columns = [
						{data:'toname'},
						{data:'supplier'},
						{data:'warehouse_code'},
						{data:'qty'},
						{data:'poname'},
						{data:'state'},
						{data:'ttime'}
					];
        		break;
        	}
			
        	$('#example1').dataTable({  
        		"lengthChange" : false,
	            "iDisplayLength" : 10, //默认显示的记录数    
				"data":data,
				"destroy": true,
				"bFilter":true,
				"aoColumns" : menu,
				"columns" : columns,
				"sPaginationType": "full_numbers",
				"bStateSave": true,
	            "oLanguage": { //国际化配置    
		            "sLengthMenu" : "显示 _MENU_ 条",    
		            "sZeroRecords" : "没有您要搜索的内容",
		            "sInfo" : "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",    
		            "sInfoEmpty" : "记录数为0",    
		            "sInfoFiltered" : "(全部记录数 _MAX_ 条)",    
		            "sInfoPostFix" : "",    
		            "sSearch" : "搜索",    
		            "sUrl" : "",    
		            "oPaginate": {    
		                "sFirst" : "第一页",    
		                "sPrevious" : "上一页",    
		                "sNext" : "下一页",    
		                "sLast" : "最后一页"    
		            }  
		    	}
			});
			$('#table_down_menu').remove();
			$('#managerList').prepend('<a target="blank" id="table_down_menu" href="{:U('Warning/execlDown')}?sku='+sku+'&type='+index+'" style="position: absolute; padding:5px 10px; background:rgb(67,142,185); z-index:999;color:#fff; margin:20px 0px 0px 16px">表格下载㊦</a>');
        }
    });
</script>
<!-- inline scripts related to this page -->
</body>
</html>
